/* 3DGo Game
 * Copyright (C) 2008 Roman Hwang, Eugene Melnichek

 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation - version 2
 * of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef _STONE_H_
#define _STONE_H_

#include "Color.h"
#include "GameObject.h"
#include <cassert>

using d3d::GameObject;

extern IDirect3DDevice9* pMyDevice;

/* 
	Class represent stone of GO. 
	Board taken from GTPInterface should be parse to Board and Stone objects
*/
class Stone
{
private:

	// Pointer to mesh
	static ID3DXMesh* m_spMesh;
	// Distance between stone spots
	static const float SPACING;
	// Stone scaling
	static const float SCALING;
	
	// position in board coordinates
	int m_i;
	int m_j;

	D3DXVECTOR3 m_position;
	D3DXMATRIX m_world;
	const D3DMATERIAL9* m_material;
	Color m_color;

public:

	Stone();
	Stone(int _i, int _j, Color _color);

	static void Init();

	void CountMatrix();

	void Render();

	inline void Set(int _i, int _j, Color _color)
	{
		SetI(_i);
		SetJ(_j);
		SetColor(_color);
		CountMatrix();
	}

	/* Field accessors */
	inline int GetI() const
	{
		return m_i;
	}

	inline void SetI(int _i)
	{
		assert(_i >= 0 && _i < 19);
		m_i = _i;
	}

	inline int GetJ() const
	{
		return m_j;
	}

	inline void SetJ(int _j)
	{
		assert(_j >= 0 && _j < 19);
		m_j = _j;
	}

	inline Color GetColor() const
	{
		return m_color;
	}

	inline void SetColor(Color _color)
	{
		m_color = _color;
	}
};

#endif // _STONE_H_